<?php
use common\components\DataHelper;
use common\models\MchAccount\MchAccount;
use yii\helpers\Url;
?>
<?php $this->beginBlock('content') ?>
<div class="row">
    <div class="col-md-4 col-xs-12">
        <div class="white-box">
            <div class="user-bg"> <!--img width="100%" alt="user" src="../plugins/images/large/img1.jpg"-->
                <div class="overlay-box">
                    <div class="user-content">
                        <a href="javascript:void(0)"><img src="<?=DataHelper::getDefaultHeaderImage()?>" class="thumb-lg img-circle" alt="img"></a>
                        <h4 class="text-white"><?=$user['username']?></h4>
                        <h5 class="text-white"><?=\common\models\Admin\Admin::getTypeMap($user["type"])?></h5> </div>
                </div>
            </div>
            <?php if (!$user->isAdmin()) : ?>
            <div class="user-btm-box">
                <div class="user-btm-box">
                    <!-- .row -->
                    <div class="row text-center">
                        <div class="col-md-6 b-r"><strong>姓名</strong>
                            <p><?=$userInfo['name']?></p>
                        </div>
                        <?php if ($user->isAgent()) : ?>
                        <div class="col-md-6"><strong>手机号码</strong>
                            <?php else :?>
                            <div class="col-md-6"><strong>支付宝账号</strong>
                                <?php endif ?>
                                <p><?=$userInfo['ali_account']?></p>
                            </div>
                        </div>
                        <!-- /.row -->
                        <hr>
                        <?php if ($user->isAgent()) : ?>
                            <!-- .row -->
                            <div class="row text-center">
                                <div class="col-md-12 b-r"><strong>上级区域经理</strong>
                                    <p><?= $userInfo['manager'] ? $userInfo['manager']["regionManagerInfo"]["name"] : "" ?></p>
                                </div>
                            </div>

                        <?php endif ?>
                        <!-- /.row -->
                        <hr>
                    </div>
                </div>
                <?php endif ?>
            </div>
        </div>
        <div class="col-md-8 col-xs-12">
            <div class="white-box">
                <ul class="nav customtab nav-tabs" role="tablist">
                    <li role="presentation" class="nav-item">
                        <a href="#settings" class="nav-link  active" aria-controls="messages" role="tab" data-toggle="tab" aria-expanded="true">
                        <span class="visible-xs">
                        <i class="fa fa-cog"></i>
                        </span>
                            <span class="hidden-xs">资料设置</span>
                        </a>
                    </li>
                </ul>
                <div class="tab-content">
                    <div id="settings">
                        <form class="form-horizontal" method="post" action="<?=Url::to(['set-info'])?>" rel-action="form" rel-before="submitBefore">
                            <div class="form-group">
                                <label class="col-md-12 form-control-label" for="">密码 <span class="help"> （不填写则不修改）</span></label>
                                <div class="col-md-12">
                                    <input input="text" onfocus="this.type='password'" name="password" value="" class="form-control" placeholder="">
                                    <div class="form-control-feedback" rel-mark="password"></div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-12 form-control-label" for="">确认密码 <span class="help"> </span></label>
                                <div class="col-md-12">
                                    <input input="text" onfocus="this.type='password'" name="password2" value="" class="form-control" placeholder="">
                                    <div class="form-control-feedback" rel-mark="password2"></div>
                                </div>
                            </div>
                            <?php if (!$user->isAdmin()) : ?>

                                <div class="form-group">
                                    <?php if ($user->isAgent()) : ?>
                                        <label class="col-md-12 form-control-label">手机号码<!--span class="help"> e.g. "George deo"</span--></label>
                                    <?php else :?>

                                        <label class="col-md-12 form-control-label">支付宝账号<!--span class="help"> e.g. "George deo"</span--></label>
                                    <?php endif ?>
                                    <div class="col-md-12">
                                        <input type="text" class="form-control" name="userInfo[ali_account]" value="<?=@$userInfo['ali_account']?>">
                                        <div class="form-control-feedback" rel-mark="userInfo[ali_account]"></div>
                                    </div>
                                </div>
                                <div class="row">
                                    <?=$this->render("@app/views/layouts/parts/cropper.php", [
                                        "col_md" => 12,
                                        "label_name" => "收钱码",
                                        "input_value" => $user->isAgent() ? @$user['agentInfo']['rev_price_image'] : $user["regionManagerInfo"]["rev_price_image"],
                                        "rel_nModule" => 0,
                                        "callback_input" => "rev_price_image",
                                        "upload_dir" =>  $user->isAgent() ? "agent" : "manager",
                                        "ratio" => 0
                                    ])?>
                                </div>
                            <?php endif ?>

                            <div class="form-group">
                                <div class="col-sm-12">
                                    <button class="btn btn-success">更新账户资料</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php $this->endBlock() ?>
    <?php $this->beginBlock("script")?>
    <script>
        function submitBefore() {
            var password = $("[name=password]").val()
            var password2 = $("[name=password2]").val()
            if ( password && password != password2 ) {
                return {
                    status: 0,
                    message: "两次密码不一致"
                }
            }
            return true;
        }
    </script>
    <?php $this->endBlock();?>
